Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
    ''' <summary>
    ''' Controller class for MemberProfile
    ''' </summary>
		<System.ComponentModel.DataObject()> Public Partial Class MemberProfileController
    
        ' Preload our schema..
        Dim thisSchemaLoad As MemberProfile = New MemberProfile()
        Private strUserName As String = String.Empty
        Protected ReadOnly Property UserName() As String
            Get
				If strUserName.Length = 0 Then
		        
    				If Not System.Web.HttpContext.Current Is Nothing Then
						strUserName = System.Web.HttpContext.Current.User.Identity.Name
					Else
		        		strUserName = System.Threading.Thread.CurrentPrincipal.Identity.Name
					End If
					Return strUserName
				End If
				Return strUserName
			End Get
        End Property
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchAll() As MemberProfileCollection
        
            Dim coll As MemberProfileCollection = New MemberProfileCollection()
            Dim qry As Query = New Query(MemberProfile.Schema)
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
            
        End Function
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByID(ByVal Memberid As Object) As MemberProfileCollection 
        
            Dim coll As MemberProfileCollection = New MemberProfileCollection().Where("memberid", Memberid).Load()
            Return coll
        
        End Function
        
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByQuery(ByVal qry As SubSonic.Query) As MemberProfileCollection 
        
            Dim coll As MemberProfileCollection = New MemberProfileCollection()
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, True)> Public Function Delete(ByVal Memberid As Object) as Boolean
        
            Return (MemberProfile.Delete(Memberid) = 1)
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, False)> Public Function Destroy(ByVal Memberid As Object) as Boolean
        
            Return (MemberProfile.Destroy(Memberid) = 1)
        
        End Function
        
    	
	    ''' <summary>
	    ''' Inserts a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Insert, True)> Public Sub Insert(ByVal Memberid As Guid,ByVal Newmsgthreshold As DateTime,ByVal Signature As String,ByVal Bio As String,ByVal Sortdesc As Boolean,ByVal Msgsperpage As Integer,ByVal Showavatars As Boolean,ByVal Showsignatures As Boolean,ByVal Sendwatchemails As Boolean,ByVal Showemail As Boolean)
	   
		    Dim item As MemberProfile = New MemberProfile()
		    
            item.Memberid = Memberid
            
            item.Newmsgthreshold = Newmsgthreshold
            
            item.Signature = Signature
            
            item.Bio = Bio
            
            item.Sortdesc = Sortdesc
            
            item.Msgsperpage = Msgsperpage
            
            item.Showavatars = Showavatars
            
            item.Showsignatures = Showsignatures
            
            item.Sendwatchemails = Sendwatchemails
            
            item.Showemail = Showemail
            
	    
		    item.Save(UserName)
	   
	   End Sub
    	
	    ''' <summary>
	    ''' Updates a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Update, True)> Public Sub Update(ByVal Memberid As Guid,ByVal Newmsgthreshold As DateTime,ByVal Signature As String,ByVal Bio As String,ByVal Sortdesc As Boolean,ByVal Msgsperpage As Integer,ByVal Showavatars As Boolean,ByVal Showsignatures As Boolean,ByVal Sendwatchemails As Boolean,ByVal Showemail As Boolean)
	    
		    Dim item As MemberProfile = New MemberProfile()
		    
				item.Memberid = Memberid
				
				item.Newmsgthreshold = Newmsgthreshold
				
				item.Signature = Signature
				
				item.Bio = Bio
				
				item.Sortdesc = Sortdesc
				
				item.Msgsperpage = Msgsperpage
				
				item.Showavatars = Showavatars
				
				item.Showsignatures = Showsignatures
				
				item.Sendwatchemails = Sendwatchemails
				
				item.Showemail = Showemail
				
		    item.MarkOld()
		    item.Save(UserName)
	    
	    End Sub
    End Class
End Namespace
